﻿using ReflectionStudio.Core;
using ReflectionStudio.Core.Events;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Xml;
namespace WPFExcelReport
{
    public partial class ITXEXRPT 
    {

        private void JLTAV37DOC(DataSet db)
        { 
            int rStart = 3;
            int nRow = 2; 
            int idx = 0; 
            DataTable tb = db.Tables["ICC_MKRF"];
            string processed = "";
            var query = (from DataRow row in tb.AsEnumerable()
                        orderby row.Field<string>("ABFBNRKRS")
                        orderby row.Field<string>("ABFBLFDNR")
                        orderby row.Field<string>("ABFBPOS")
                        orderby row.Field<decimal>("MKFPLDATV")
                        orderby row.Field<decimal>("MKFPLTIME")
                        select row).Distinct();
            foreach (DataRow row in query)
            {
                string order=row["ABFAUFKRS"].ToString()+"-"+Helpers.Helper.GetSubRollNum(row["ABFAUFLFD"].ToString()) 
                    + "-" +Helpers.Helper.GetSubRollNum(row["ABFAUFPOS"].ToString());
                if (!processed.Contains(order + ";"))
                {
                    processed += order + ";";
                }
                else
                {
                    continue;
                }
                exAgent.SetCellValue(rStart+idx*nRow, 1,Helpers.Helper.GetSubRollNum(row["ABFBLFDNR"].ToString()) + "-" +Helpers.Helper.GetSubRollNum(row["ABFBPOS"].ToString()));
                exAgent.SetCellValue(rStart+idx*nRow, 2, row["MKFPLDATV"].ToString());
                exAgent.SetCellValue(rStart+idx*nRow, 3, row["MKFSCHICHTV"].ToString());
                exAgent.SetCellValue(rStart+idx*nRow, 4,order);
                exAgent.SetCellValue(rStart+idx*nRow, 5, row["ABPART"].ToString().Trim());
                exAgent.SetCellValue(rStart+idx*nRow, 6, row["ABPFARBE"].ToString().Trim());
                exAgent.SetCellValue(rStart+idx*nRow, 7, Convert.ToDecimal(row["ABFSOLLMG"].ToString().Trim())/1000);
                idx++;
            } 
        } 
    }
}